//
//  CustomImageVIewAnimate.m
//  UI_作业05
//
//  Created by zhuziming on 16/6/11.
//  Copyright © 2016年 zuzhiming. All rights reserved.
//

#import "CustomImageVIewAnimate.h"

@implementation CustomImageVIewAnimate

- (instancetype)initWithFrame:(CGRect)frame ImageCount:(NSInteger)imageCount ImageString:(NSString *)imageString

{
    self = [super initWithFrame:frame];
        //初始化存放图片的数组
        NSMutableArray *animationsArray = [NSMutableArray array];
        for (NSInteger i = 0; i < imageCount; i++) {
            NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@_%ld",imageString, i] ofType:@"jpg"];
            UIImage *image = [UIImage imageWithContentsOfFile:path];
            [animationsArray addObject:image];
        }
        //将图片数组装箱
        self.animationImages = animationsArray;
        //设置动画持续时间
        self.animationDuration = 2.0f;
        self.animationRepeatCount = 1;
        //开始动画
        [self startAnimating];

        return self;
}
@end
